﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;

using DbAccessLib;

namespace DataAccess
{
    public class TenDiaDiemDAO
    {
        static private TenDiaDiemDAO m_DAO = new TenDiaDiemDAO();

        static public TenDiaDiemDAO DAO
        {
            get { return m_DAO; }
        }

        public DataTable layDanhSachTenDiaDiem()
        {
            String CommandText = " SELECT TenDiaDiem FROM TENDIADIEM; ";

            SQLStatement cmd = Db.DiaDiemDB.CreateStatement(CommandText);

            return cmd.ExecuteQuery();
        }

        public DataTable layDanhSachTuKhoaTenDiaDiem()
        {
            String CommandText = "SELECT TuKhoaTenDiaDiem FROM TUKHOADIADIEM;";
            SQLStatement cmd = Db.DiaDiemDB.CreateStatement(CommandText);

            return cmd.ExecuteQuery();
        }

        public int layMaTenDiaDiem(String TuKhoaTenDiaDiem)
        {
            String CommandText = "SELECT MaTenDiaDiem FROM TUKHOADIADIEM WHERE TuKhoaTenDiaDiem like ?;";
            SQLStatement cmd = Db.DiaDiemDB.CreateStatement(CommandText);

            cmd.bindParam("?", TuKhoaTenDiaDiem, OleDbType.VarChar);
            return Convert.ToInt32(cmd.ExecuteScalar());
        }
    }
}
